'''
Created on 2009-8-31

@author: lz
'''

def decrypt_MappingDown(filename):
    
    f = open(filename, 'rb')
    buffer = f.read()
    f.close()

    pattern_begin = 'kwws'
    pattern_end = '\0'

    try:
        http_begin = buffer.index(pattern_begin)
        http_end = buffer.index(pattern_end, http_begin)
        crypt_s = buffer[http_begin:http_end]
        return "".join([chr(ord(t) ^ 3 ) for t in crypt_s])
    except:
        return
    return li

def minus26(s):
    li = []
    for t in range(0, len(s)):
        li.append(ord(s[t]) + 23 - 2*t)

    return "".join([chr(t) for t in li])

def decrypt_SysDllDown(filename):
    
    f = open(filename, 'rb')
    buffer = f.read()
    f.close()

    pattern_begin = '\x51\x5F\x61\x5F'
    pattern_end = '\0'

    try:
        http_begin = buffer.index(pattern_begin)
        http_end = buffer.index(pattern_end, http_begin)
        crypt_s = buffer[http_begin:http_end]
        return minus26(crypt_s)
    except:
        return
    return li

if __name__ == '__main__':
    pass